package objectClasses;

import java.io.Serializable;
import java.math.BigInteger;
import java.security.SecureRandom;

import javax.swing.ImageIcon;


public class Entry implements Serializable{
	/**
	 * Used to serialize and deserialize
	 */
	private static final long serialVersionUID = -5541282181395510306L;
	/**
	 * Their loginname
	 */
	private String Username;
	/**
	 * The description about their materials
	 */
	private String Materials;
	/**
	 * Randomly assigned number for the event
	 */
	private String idnumber;
	/**
	 * Their category
	 */
	private String Category;
	/**
	 * Abe's draft class must use submit buttont o get this or null
	 */
	private Draft myDraft;
	
	
	/**
	 * Constructor if an entry is new 
	 * @param User The persons username
	 * @param Con_Materials THe type of materials they used
	 * @param Cat The category of the entry
	 * @param filePath Where I may find the image 
	 */
	public Entry(String User, String Con_Materials, String Cat, Draft the_draft){
		if(User==null||Con_Materials==null||Cat==null||the_draft==null){
			throw new NullPointerException();
		}
		Materials = Con_Materials;
		Category = Cat;
		Username = User;
		idnumber = assignID();
		myDraft= the_draft;
	}
	/**
	 * COnstructor for loading entries in from the file
	 * @param User The persons username
	 * @param Con_Materials THe type of materials they used
	 * @param Cat The category of the entry
	 * @param filePath Where I may find the image 
	 * @param ID their ID number
	 */
	public Entry(String User, String Con_Materials, String Cat, String ID, Draft the_draft){
		if(User==null||Con_Materials==null||Cat==null||the_draft==null||ID==null){
			throw new NullPointerException();
		}
		Username = User;
		Materials = Con_Materials;	
		Category = Cat;
		idnumber = ID;
		myDraft = the_draft;
	}

	  /**
	   * Used to generate the ID number
	   * @return id number
	   */
	private String assignID(){
		SecureRandom random = new SecureRandom();
		return new BigInteger(20, random).toString(32);
	}
	public String getUsername(){
		return Username;
	}
	
	public String getIdNumber(){
		return idnumber;
	}

	public String getEntryMaterialsString(){
		return Materials;
	}
	
	public String getCategory(){
		return Category;
	}
	
	
	public Draft getMyDraft() {
		return myDraft;
	}

	
		
	


}
